/**
 * 重写webpack配置
 */
const { override, fixBabelImports, addWebpackAlias, addLessLoader, addDecoratorsLegacy, addWebpackModuleRule, addWebpackPlugin } = require('customize-cra');
const path = require('path');
const HtmlWebpackPlugin =require('html-webpack-plugin')

module.exports = override(
   fixBabelImports('import', {
     libraryName: 'antd-mobile',
     style: 'css',
   }),
  addWebpackAlias({
      ["@src"]: path.resolve(__dirname, "src"),
      ["@common"]: path.resolve(__dirname, "src/common"),
      ["@components"]: path.resolve(__dirname, "src/components"),
  }),
  addLessLoader({
    javascriptEnabled: true,        
        modifyVars: { 
            '@primary-color': '#1DA57A' 
        }    
  }),
  addDecoratorsLegacy(), //增加装饰器
  addWebpackModuleRule({
    test: /\.html$/,
    use: [
      {
        loader: require.resolve('html-loader')
      }
    ]

  }),
  // // 多导出一个login.html文件，且吧login/index.js强行引入到html文件当中；
  // addWebpackPlugin(new HtmlWebpackPlugin({
  //   filename: 'login.html',
  //   template: './src/Login/index.html',
  //   inject: true,
  //   chunks: ['login']
  // })),
  // (config) => {
  //   config.entry={
  //     'index': './src/index.js',
  //     'login': './src/Login/index.js'
  //   }
  // return config
  // }
 );